package com.ysd.lis.controller;

import cn.com.jit.new_vstk.AdvanceSignClient;
import cn.com.jit.new_vstk.Bean.VerifyResult;
import cn.com.jit.new_vstk.exception.NewCSSException;
import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.ysd.common.Result;
import com.ysd.lis.annotation.LogDetail;
import com.ysd.lis.aspect.OperationType;
import com.ysd.lis.controller.pub.BaseController;
import com.ysd.lis.dto.CALogDto;
import com.ysd.lis.dto.SignDto;
import com.ysd.lis.entity.*;
import com.ysd.lis.mapper.sys.SysEventLogMapper;
import com.ysd.lis.mapper.sys.SysInterfaceMapper;
import com.ysd.lis.service.SysInterfaceCaUserService;
import com.ysd.lis.service.SysUserAuthdetailService;
import com.ysd.lis.service.SysUserService;
import com.ysd.util.JwtUtils;
import com.ysd.util.RedisCaptcha;
import com.ysd.util.RedisUserManager;
import com.ysd.util.UniqueIdGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.FileOutputStream;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;

@Api(value = "用户登录")
@RestController
@RequestMapping("/public/user")
public class LoginController extends BaseController {
    private static final Logger logger = Logger.getLogger(LoginController.class.getName());

    @Value("${picturePath}")
    private String picturePath;

    private static final long REDIS_TIME = 30 * 24 * 60 * 60;
    @Autowired
    private SysUserService userService;
    @Autowired
    private SysEventLogMapper sysEventLogMapper;
    @Autowired
    private SysUserAuthdetailService sysUserAuthdetailService;
    @Autowired
    SysInterfaceMapper sysInterfaceMapper;
    @Autowired
    SysInterfaceCaUserService sysInterfaceCaUserService;


    /**
     * 是否开启验证码
     */
    @Value("${verifyCode.enabled}")
    private boolean enabled;

    @ApiOperation(value = "用户登录", notes = "登录--不进行拦截")
    @PostMapping("/login")
//    @LogDetail(requestParam ="login",operationType = OperationType.LOGON, module = "用户登录",content = "登录LIS系统")
    public Result login(@Validated @RequestBody LoginDto loginDto, HttpServletRequest request) {
        //获得存储在redis中的验证码（不会shiro的不用管，看这有关验证码的就行）
        if (enabled) {
            if (StringUtils.isBlank(loginDto.getVerifyCode())) {
                return Result.fail("请输入验证码");
            }
            if (StringUtils.isBlank(loginDto.getKeyId())) {
                return Result.fail("获取KeyId失败，请检查redis缓存是否开启");
            }
            String redisCode = RedisCaptcha.getCaptcha(loginDto.getKeyId());
            if (StringUtils.isBlank(redisCode)) {
                return Result.fail("获取验证码失败，请检查缓存是否开启");
            }
            if (!redisCode.equals(loginDto.getVerifyCode())) {
                return Result.fail("验证码失效，请重新获取验证码");
            }
        }
        String username = loginDto.getUsername();
        String passwords = SecureUtil.md5(loginDto.getPassword());
        SysUser sysUser = userService.getPassword(username);
        if (sysUser == null) {
            return Result.fail("用户不存在", null);
        } else {
            String realPassword = sysUser.getPassword();
            if (!realPassword.equals(passwords)) {
                return Result.fail("密码错误", null);
            } else {
                String token = JwtUtils.createToken(username, sysUser.getId());
                RedisUserManager.storeUser(token, sysUser);

                RedisUserManager.storeOrg("currentOrg" + token, sysUser.getOrgId());

                try {
                    if (enabled) {
                        //移除验证码
                        RedisCaptcha.destroyCaptcha(loginDto.getKeyId());
                    }
                } catch (Exception e) {
                    logger.log(Level.SEVERE, "An exception occurred", e);
                    return Result.fail("登录异常，请务必检查redis相关配置");
                }
                return Result.succ(1, "登录成功", MapUtil.builder()
                        .put("user", sysUser)
                        .put("token", token)
                        .map()
                );
            }
        }
    }

    @ApiOperation(value = "生成随机数")
    @GetMapping("/generateRandom")
    public Result generateRandom() {
        try {
            String length = "10"; //产生的随机数长度
            AdvanceSignClient client = new AdvanceSignClient("E:\\Limp\\lis_server\\conf\\cssconfig.properties");

            byte[] result = client.generateRandom(length, "16");//长度为length的十六进制随机数结果
            String string = Base64.getEncoder().encodeToString(result);
            return Result.succ(1, "生成成功", string);
        } catch (NewCSSException e) {
            Map<String, String> map = new HashMap<>();
            map.put("code", e.getCode());
            map.put("description", e.getDescription());
            map.put("serialNumber", e.getSerialNumber());
            return Result.fail(map.toString());
        }
    }

    @ApiOperation(value = "优抚验证签名")
    @PostMapping("/detachSign")
    public Result detachSign(@RequestBody SignDto signDto) {
        try {

            AdvanceSignClient client = new AdvanceSignClient("E:\\Limp\\lis_server\\conf\\cssconfig.properties");
            VerifyResult verify = client.verify(signDto.getSignData().getBytes(), signDto.getPlain().getBytes());

            return Result.succ(1, "生成成功", verify);
        } catch (NewCSSException e) {
            Map<String, String> map = new HashMap<>();
            map.put("code", e.getCode());
            map.put("description", e.getDescription());
            map.put("serialNumber", e.getSerialNumber());
            return Result.fail(map.toString());
        }
    }

    @ApiOperation(value = "用户登录", notes = "登录--不进行拦截")
    @PostMapping("/loginH5")
    public Result loginH5(@Validated @RequestBody LoginDto loginDto, HttpSession session) {
        String username = loginDto.getUsername();
        String passwords = SecureUtil.md5(loginDto.getPassword());
        SysUser sysUser = userService.getPassword(username);
        if (sysUser == null) {
            return Result.fail("用户不存在", null);
        } else {
            String realPassword = sysUser.getPassword();
            if (!realPassword.equals(passwords)) {
                return Result.fail("密码错误", null);
            } else {
                //移除验证码
                session.removeAttribute("verificationCode");
                return Result.succ(1, "登录成功", MapUtil.builder()
                        .put("user", sysUser)
                        //      .put("token", JwtUtils.createToken(username, sysUser.getId())) 上线的话务必放开，注释下面的代码
                        .put("token", "123456")
                        .map()
                );
            }
        }
    }

    @ApiOperation(value = "用户登录", notes = "登录--不进行拦截")
    @PostMapping("/loginByUserName")
    public Result loginByUserName(@Validated @RequestBody LoginDto loginDto, HttpSession session) {
        if (StringUtils.isBlank(loginDto.getKeyId())) {
            return Result.fail("密钥值不允许为空", null);
        }
        String username = loginDto.getUsername();
        SysUser sysUser = userService.getPassword(username);
        if (sysUser == null) {
            return Result.fail("用户不存在", null);
        } else {
            String token = JwtUtils.createToken(username, sysUser.getId());
            RedisUserManager.storeUser(token, sysUser);

            RedisUserManager.storeOrg("currentOrg" + token, sysUser.getOrgId());
            return Result.succ(1, "登录成功", MapUtil.builder().put("user", sysUser).put("token", token).map());
        }
    }

    @ApiOperation(value = "用户登录", notes = "登录--不进行拦截")
    @PostMapping("/loginByOther")
    public Result loginByOther(@Validated @RequestBody LoginDto loginDto) {
        String url = "http://172.16.17.102:9556/api-auth/oauth/userinfo?access_token=" + loginDto.getToken();
        String result = HttpUtil.createGet(url).execute().body();
        JSONObject jsonObject = JSONUtil.parseObj(result);
        String resp_code = (String) jsonObject.get("resp_code");
        if (resp_code.equals("200")) {
            String username = loginDto.getUsername();
            String passwords = SecureUtil.md5(loginDto.getPassword());
            SysUser sysUser = userService.getPassword(username);
            if (sysUser == null) {
                return Result.fail("用户不存在", null);
            } else {
                return Result.succ(1, "登录成功", MapUtil.builder()
                        .put("user", sysUser)
                        .put("token", JwtUtils.createToken(username, sysUser.getId()))
                        .map()
                );

            }

        } else {
            return Result.fail(Integer.valueOf(resp_code), "access_token不识别", null);
        }
    }

    @ApiOperation(value = "用户登录", notes = "登录--不进行拦截")
    @PostMapping("/loginByToken")
    public Result loginByToken(@Validated @RequestBody LoginDto loginDto) {
        String username = JwtUtils.getUsername(loginDto.getToken());
        if (StringUtils.isNotBlank(username)) {
            String userId = JwtUtils.getUserId(loginDto.getToken());
            String passwords = SecureUtil.md5(loginDto.getPassword());
            SysUser sysUser = userService.getPassword(username);
            if (sysUser == null) {
                return Result.fail("用户不存在", null);
            } else {
                return Result.succ(1, "登录成功", MapUtil.builder()
                        .put("user", sysUser)
                        .put("token", JwtUtils.createToken(username, sysUser.getId()))
                        .map()
                );

            }

        } else {
            return Result.fail("token错误！", null);
        }
    }

    @ApiOperation(value = "Vip用户访问", notes = "拥有 vip 权限可以访问该页面")
    @PostMapping("/getVipMessage")
    @RequiresPermissions("SY0qqq1")
    public Result getVipMessage() {
        return Result.succ("");
    }

    //生成验证码
    @GetMapping("/getVerificationCode")
    public Result getVerificationCode(HttpServletRequest request, HttpSession session) {
        // 定义图形验证码的长、宽、验证码位数、线性数量
        //还有更多功能自行研究，这里只做简单实现
        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(125, 50, 4, 5);
        String keyId = String.valueOf(UniqueIdGenerator.generateUniqueId());
        try {
            RedisCaptcha.saveCaptcha(keyId, lineCaptcha.getCode());//存储验证码
        } catch (Exception e) {
            return Result.fail("获取验证码失败，请检查redis相关配置");
        }
        Map map = new HashMap();
        map.put("verifyImage", lineCaptcha.getImageBase64());
        map.put("keyId", keyId);
        return Result.succ(1, "获取验证码成功", map);
    }

    //退出登录调取接口
    @ApiOperation(value = "退出登录")
    @PostMapping("/LoginOut")
    @LogDetail(requestParam = "LoginOut", operationType = OperationType.LOGONOUT, module = "退出登录", content = "退出系统")
    public Result LoginOut() {
        //清除原有登录留下的缓存数据 以后再有别的缓存销毁在此方法中增加销毁，由于需要记录日志信息，放在了切面中销毁用户信息

        return Result.succ(1, "退出成功", null);
    }

    @ApiOperation(value = "查询用户名和组织机构")
    @GetMapping("/getUserName/{userName}")
    public Result getUserNameAndOrgName(@PathVariable("userName") String userName) {
        return userService.getUserNameAndOrgName(userName);
    }

    @ApiOperation(value = "切换组织机构")
    @GetMapping("/changeOrg")
    public Result changeOrg(String orgId) {
        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = requestAttributes.getRequest();
        String token = request.getHeader("Authorization").replace("Bearer ", "");
        RedisUserManager.storeOrg("currentOrg" + token, orgId);
        return Result.succ(1, "切换成功", null);
    }

    @GetMapping("/getSSODataByToken")
    public Result getSSODataByToken(String url, String token) {
        Map returnMap = new HashMap();
        Map map = new HashMap<>();
        map.put("token", token);
        try {
            String body = HttpUtil.createPost(url).body(JSONUtil.toJsonStr(map)).contentType("application/json").execute().body();
            JSONObject jsonObject = JSONUtil.parseObj(body);
            String username = (String) jsonObject.getJSONObject("data").get("username");
            SysUser sysUser = userService.getPassword(username);
            if (BeanUtil.isNotEmpty(sysUser)) {
                Result loginUserAuthMapByUserId = sysUserAuthdetailService.getLoginUserAuthMapByUserId(sysUser.getId());
                String token1 = JwtUtils.createToken(username, sysUser.getId());
                RedisUserManager.storeUser(token1, sysUser);
                RedisUserManager.storeOrg("currentOrg" + token1, sysUser.getOrgId());
                returnMap.put("user", sysUser);
                returnMap.put("token", token1);
                returnMap.put("auth", loginUserAuthMapByUserId.getData());
            } else {
                return Result.fail("根据token未查到用户信息");
            }
        } catch (Exception e) {
            return Result.fail("单点登录获取用户信息失败");
        }
        return Result.succ(returnMap);
    }

    @ApiOperation(value = "获取CA登录二维码")
    @GetMapping("/getCAScanCode")
    public Result getCAScanCode() {
        LambdaQueryWrapper<SysInterface> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SysInterface::getDelFlag, 0);
        wrapper.eq(SysInterface::getIsEnable, 1);
        List<SysInterface> sysInterfaces = sysInterfaceMapper.selectList(wrapper);
        List<String> collect = sysInterfaces.stream().filter(o -> Objects.nonNull(o) && StringUtils.isNotBlank(o.getInterfaceUrl())).map(SysInterface::getInterfaceUrl).distinct().collect(Collectors.toList());

        try {
            if (CollectionUtils.isNotEmpty(collect)) {
                for (String webUrl : collect) {
                    SysOrgDepartment sysOrgDepartment = new SysOrgDepartment();
                    String returnMsg1 = HttpUtil.createPost(webUrl + "/lisRestFul/CALogin").body(JSONUtil.toJsonStr(sysOrgDepartment)).contentType("application/json").execute().body();
                    JSONObject reportObject = new JSONObject(returnMsg1);
                    JSONObject reportStatus = reportObject.getJSONObject("status");
                    String reportCode = reportStatus.get("code").toString();
                    if ("400".equals(reportCode)) {
                        return Result.fail("接口管理平台异常,请检查");
                    } else {
                        return Result.succ(1, "成功", reportObject.getJSONObject("data"));
                    }
                }
            }
        } catch (Exception e) {
            throw new RuntimeException("接口管理平台异常,请检查");
        }
        return Result.fail("获取CA登录信息失败");
    }

    @ApiOperation(value = "校验是否已经扫码")
    @GetMapping("/checkIsScan")
    public Result checkIsScan(String signDataId) {
        LambdaQueryWrapper<SysInterface> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SysInterface::getDelFlag, 0);
        wrapper.eq(SysInterface::getIsEnable, 1);
        List<SysInterface> sysInterfaces = sysInterfaceMapper.selectList(wrapper);
        List<String> collect = sysInterfaces.stream().filter(o -> Objects.nonNull(o) && StringUtils.isNotBlank(o.getInterfaceUrl())).map(SysInterface::getInterfaceUrl).distinct().collect(Collectors.toList());

        try {
            if (CollectionUtils.isNotEmpty(collect)) {
                for (String webUrl : collect) {
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.set("signDataId", signDataId);
                    String returnMsg1 = HttpUtil.createPost(webUrl + "/lisRestFul/checkIsScan").body(JSONUtil.toJsonStr(jsonObject)).contentType("application/json").execute().body();
                    JSONObject reportObject = new JSONObject(returnMsg1);
                    JSONObject reportStatus = reportObject.getJSONObject("status");
                    String reportCode = reportStatus.get("code").toString();
                    if ("400".equals(reportCode)) {
                        return Result.fail("接口管理平台异常,请检查");
                    } else {
                        //获取userId查询表获取用户信息
                        //todo
                        String userId = reportObject.getJSONObject("data").getStr("userId");
                        if (StrUtil.isNotEmpty(userId)) {
                            LambdaQueryWrapper<SysInterfaceCaUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
                            lambdaQueryWrapper.eq(SysInterfaceCaUser::getCaUserId, userId).eq(SysInterfaceCaUser::getDelFlag, 0);
                            List<SysInterfaceCaUser> list = sysInterfaceCaUserService.list(lambdaQueryWrapper);
                            SysUser sysUser = userService.getPassword(list.get(0).getUsername());
                            sysUser.setCaUserId(userId);
                            String token = JwtUtils.createToken("admin", sysUser.getId());
                            RedisUserManager.storeUser(token, sysUser);
                            RedisUserManager.storeOrg("currentOrg" + token, sysUser.getOrgId());
                            return Result.succ(1, "登录成功", MapUtil.builder()
                                    .put("user", sysUser)
                                    .put("token", token)
                                    .map()
                            );
                        } else {
                            return Result.succ(1, "成功", null);
                        }

                    }
                }
            }
        } catch (Exception e) {
            throw new RuntimeException("接口管理平台异常,请检查");
        }
        return Result.fail("获取CA登录信息失败");
    }


    @ApiOperation(value = "山东CA登录")
    @PostMapping("/sdcaLogin")
    public Result sdcaLogin(@RequestBody CALogDto caLogDto) {
        //获取userId查询表获取用户信息
        if (StrUtil.isNotEmpty(caLogDto.getUsername())) {
            LambdaQueryWrapper<SysUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
            lambdaQueryWrapper.eq(SysUser::getInitializer, caLogDto.getUsername()).eq(SysUser::getDelFlag, 0);
            List<SysUser> list = userService.list(lambdaQueryWrapper);
            if (CollectionUtils.isNotEmpty(list)) {
                SysUser sysUser = list.get(0);
                if (StrUtil.isNotEmpty(caLogDto.getBase64Image())) {
                    byte[] buffer = Base64.getDecoder().decode(caLogDto.getBase64Image()); //将base64字符串转为字节
                    FileOutputStream out = null; //创建一个FileOutputStream对象
                    String folder = picturePath + File.separator + "CA";
                    if (!FileUtil.exist(folder)) {
                        FileUtil.mkdir(folder);
                    }
                    String fileName = sysUser.getInitializer() + "-" + sysUser.getRealname() + ".jpg";
                    try {
                        out = new FileOutputStream(folder + File.separator + fileName); //向文件中写入数据
                        out.write(buffer); //将字节数据写入到文件中
                    } catch (Exception e) {
                        e.printStackTrace();
                    } finally {
                        if (null != out) {
                            try {
                                out.close();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                    //根据userId更新签名图片
                    SysUser sysUser1 = new SysUser();
                    sysUser1.setCaSignUrl(File.separator + "image" + File.separator + "CA" + File.separator + fileName);
                    sysUser1.setId(sysUser.getId());
                    userService.updateById(sysUser1);
                }
                String token = JwtUtils.createToken(sysUser.getUsername(), sysUser.getId());
                RedisUserManager.storeUser(token, sysUser);
                RedisUserManager.storeOrg("currentOrg" + token, sysUser.getOrgId());
                return Result.succ(1, "登录成功", MapUtil.builder()
                        .put("user", sysUser)
                        .put("token", token)
                        .map()
                );
            }
        }
        return Result.fail("获取CA登录信息失败");
    }

    @ApiOperation(value = "优抚CA登录")
    @PostMapping("/yfcaLogin")
    public Result yfcaLogin(@RequestBody CALogDto caLogDto) {
        //获取userId查询表获取用户信息
        if (StrUtil.isNotEmpty(caLogDto.getCaUserId())) {
            LambdaQueryWrapper<SysUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
            lambdaQueryWrapper.eq(SysUser::getInitializer, caLogDto.getCaUserId())
                    .eq(SysUser::getDelFlag, 0);
            List<SysUser> list = userService.list(lambdaQueryWrapper);
            if (CollectionUtils.isNotEmpty(list)) {
                SysUser sysUser = list.get(0);
                String token = JwtUtils.createToken(sysUser.getUsername(), sysUser.getId());
                RedisUserManager.storeUser(token, sysUser);
                RedisUserManager.storeOrg("currentOrg" + token, sysUser.getOrgId());
                return Result.succ(1, "登录成功", MapUtil.builder()
                        .put("user", sysUser)
                        .put("token", token)
                        .map()
                );
            }
        }
        return Result.fail("登录失败");
    }


    @ApiOperation(value = "校验是否已经扫码")
    @GetMapping("/getCaUserInfo")
    public Result getCaUserInfo(String tel, String idCard, String username, String realname) {
        LambdaQueryWrapper<SysInterface> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SysInterface::getDelFlag, 0);
        wrapper.eq(SysInterface::getIsEnable, 1);
        List<SysInterface> sysInterfaces = sysInterfaceMapper.selectList(wrapper);
        List<String> collect = sysInterfaces.stream().filter(o -> Objects.nonNull(o) && StringUtils.isNotBlank(o.getInterfaceUrl())).map(SysInterface::getInterfaceUrl).distinct().collect(Collectors.toList());

        try {
            if (CollectionUtils.isNotEmpty(collect)) {
                for (String webUrl : collect) {
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.set("tel", tel);
                    jsonObject.set("idCard", idCard);
                    jsonObject.set("username", realname);
                    String returnMsg1 = HttpUtil.createPost(webUrl + "/lisRestFul/getCAUserInfo").body(JSONUtil.toJsonStr(jsonObject)).contentType("application/json").execute().body();
                    JSONObject reportObject = JSONUtil.parseObj(returnMsg1);
                    System.out.println(reportObject);
                    JSONObject reportStatus = reportObject.getJSONObject("status");
                    String signImage = reportObject.getJSONObject("data").getStr("signimg");
                    String userId = reportObject.getJSONObject("data").getStr("userId");
                    if (StrUtil.isNotEmpty(signImage) && StrUtil.isNotEmpty(userId)) {
                        byte[] buffer = Base64.getDecoder().decode(signImage); //将base64字符串转为字节
                        FileOutputStream out = null; //创建一个FileOutputStream对象
                        String folder = picturePath + "\\" + "CA";
                        if (!FileUtil.exist(folder)) {
                            FileUtil.mkdir(folder);
                        }
                        String fileName = System.currentTimeMillis() + ".jpg";
                        try {
                            out = new FileOutputStream(folder + "\\" + fileName); //向文件中写入数据
                            out.write(buffer); //将字节数据写入到文件中
                        } catch (Exception e) {
                            e.printStackTrace();
                        } finally {
                            if (null != out) {
                                try {
                                    out.close();
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        }
                        //根据userId更新签名图片
                        LambdaQueryWrapper<SysUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
                        lambdaQueryWrapper.eq(SysUser::getUsername, username).eq(SysUser::getDelFlag, 0);
                        SysUser sysUser = new SysUser();
                        sysUser.setCaSignUrl("/image/CA/" + fileName);
                        userService.update(sysUser, lambdaQueryWrapper);
                    }
                    String reportCode = reportStatus.get("code").toString();
                    if ("400".equals(reportCode)) {
                        return Result.fail("接口管理平台异常,请检查");
                    } else {
                        //获取userId查询表获取用户信息
                        return Result.succ(1, "查询成功", reportObject.getJSONObject("data"));
                    }
                }
            }
        } catch (Exception e) {
            throw new RuntimeException("接口管理平台异常,请检查");
        }
        return Result.fail("获取CA登录信息失败");
    }

}
